//
//  AgreementViewController.m
//  QXLoginManage
//
//  Created by Admin on 16/12/21.
//  Copyright © 2016年 suncong. All rights reserved.
//

#import "H5ViewController.h"
#import <MBProgressHUD_QXUtils/MBProgressHUD+QXUtils.h>
@interface H5ViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *agressWebView;
@end

@implementation H5ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.title = _h5Title;
    NSURL *url = [NSURL URLWithString:_h5RequestURL];
    [self.agressWebView loadRequest:[NSURLRequest requestWithURL:url]];
    self.agressWebView.delegate = self;
    
    UIFont *tempFont = [UIFont systemFontOfSize:16];
    UIColor *tempColor = [UIColor colorWithRed:107/255.0 green:120/255.0 blue:134/255.0 alpha:1];
    if (self.titleFont) {
        tempFont = self.titleFont;
    }
    if (self.titleColor) {
        tempColor = self.titleColor;
    }
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:tempFont,NSForegroundColorAttributeName:tempColor}];
}

- (void)setH5RequestURL:(NSString *)h5RequestURL{
    
    _h5RequestURL = h5RequestURL;
}

- (void)setH5Title:(NSString *)h5Title{
    
    _h5Title = h5Title;
}

+(instancetype)shareViewController
{
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    NSURL *url = [bundle URLForResource:@"H5Manager" withExtension:@"bundle"];
    H5ViewController *vc = [[UIStoryboard storyboardWithName:@"H5Storyboard" bundle:[NSBundle bundleWithURL:url]]instantiateViewControllerWithIdentifier:@"H5ViewController"];
    return vc;
}

- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)backAction:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark webView代理
- (void )webViewDidStartLoad:(UIWebView  *)webView{
    
    
    [MBProgressHUD loadingWithText:@"" onView:self.view];
}
- (void )webViewDidFinishLoad:(UIWebView  *)webView{
    
    
    [MBProgressHUD hiddenHUDForView:self.view];
}
- (void)webView:(UIWebView *)webView  didFailLoadWithError:(NSError *)error{
    
    
    [MBProgressHUD showWithText:@"加载失败" onView:self.view hiddenDuration:1.5];
}

#pragma mark view代理方法
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}


@end
